/*
 * Copyright 2009 Brook Smith brook.smith@paradise.net.nz.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package org.javagenerate.generator.script;

public class OptionsDefinition {
	public static void main(String[] args) {
		OptionsDefinition definition = new OptionsDefinition("Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)");

		System.out.println(definition.getFullOption());
		System.out.println(definition.getOption());
		System.out.println(definition.getOptionsParms());
	}

	private String option = null;

	public OptionsDefinition(String option) {
		this.option = option;
	}

	@Override
	public boolean equals(Object arg0) {
		return ((OptionsDefinition) arg0).getOption().equals(option);
	}

	public String getFullOption() {
		return option;
	}

	/**
	 * 
	 * @return just tht name of the option
	 */
	public String getOption() {
		if (option.contains("(")) {
			return option.substring(0, option.indexOf("(")).trim();
		}
		return option;
	}

	public String getOptionsParms() {
		if (option.contains("(")) {
			return option.substring(option.indexOf("(")).trim();
		}
		return "";
	}

	@Override
	public int hashCode() {
		return getOption().hashCode();
	}

}
